# !/usr/bin/env python
# -*-coding:utf-8 -*-
"""
@Author : Ayao
@Time   : 2022/5/19
@File   : 移动零.py
"""
# https://leetcode.cn/leetbook/read/array-and-string/c6u02/
from typing import List


class Solution:
    def moveZeroes(self, nums: List[int]) -> None:
        """
        Do not return anything, modify nums in-place instead.
        """
        slow, length = 0, len(nums)
        for fast in range(length):
            if nums[slow] == 0 and nums[fast] != 0:
                nums[slow], nums[fast] = nums[fast], nums[slow]
                slow += 1
            if nums[fast] == 0 and nums[slow] != 0:
                slow = fast


if __name__ == '__main__':
    solution = Solution()

    nums = [0, 1, 0, 3, 12]
    solution.moveZeroes(nums)
    print(nums)

    nums = [1, 0, 1]
    solution.moveZeroes(nums)
    print(nums)
